package br.com.caelum.lojavirtual.main;



import java.util.List;

import br.com.caelum.lojavirtual.dao.Dao;
import br.com.caelum.lojavirtual.dao.DaoFactory;
import br.com.caelum.lojavirtual.modelo.Usuario;

public class TestaUsuario {
	public static void main(String[] args) {
		
		
		Usuario u = new Usuario();
		u.setLogin("admin");
		u.setSenha("admin");
		String[] s = {"admin","manager"};
		u.setRole(s);
		DaoFactory daoFactory = new DaoFactory();
		Dao<Usuario, Long> dao = daoFactory.getUsuarioDao();
		daoFactory.beginTransaction();
		
		dao.adiciona(u);
		
		
		List<Usuario> lista = dao.listaTudo();
		for (Usuario usuario : lista) {
			System.out.println(usuario.getLogin());
		}
		daoFactory.commit();
		
	}
}
